package com.example.feign.web;

import com.example.api.service.Client1Service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @author wangxianchen
 * @create 2017-12-25
 * @desc
 */
@RestController
@RefreshScope  //利用bus总线动态刷新配置中心变量，这个声明表示当前类接收刷新
public class FeignController {
    private static Logger logger = LoggerFactory.getLogger(FeignController.class);


    //@Autowired
    //FeignService feignService;

    @Autowired
    Client1Service client1Service;

    @Value("${spring.application.name}")
    String appName;

    @Value("${myBusVar:''}")
    String myBusVar;


    @RequestMapping("/hello")
    public Object adminInfo(HttpServletRequest request){
        return "SERVICE "+ appName +" is running. myBusVar="+myBusVar;
    }


   // @RequestMapping(value = "/hi")
    //public String hi(@RequestParam String name){
    //    return feignService.hi(name);
   // }

    @RequestMapping(value = "/he")
    public String he(@RequestParam String name){
        return client1Service.hi(name);
    }
}
